// =================================================================================================
//
//	CopyEngine Framework
//	Copyright 2012 Eran. All Rights Reserved.
//
//	This program is free software. You can redistribute and/or modify it
//	in accordance with the terms of the accompanying license agreement.
//
// =================================================================================================

package gui.viewport
{
    import flash.display.MovieClip;
    import flash.events.MouseEvent;
    import flash.text.TextField;

    import manger.LogicManger;

    public class ViewportOperator
    {
        private var mOperatorMc:MovieClip;
        private var mManger:LogicManger;

        private var mChangeScreenSizeConfirmBtn:MovieClip;
        private var mOriginalViewportSizeBtn:MovieClip;
        private var mFixViewportSizeBtn:MovieClip;
        private var mScreenWithTF:TextField;
        private var mScreenHeightTF:TextField;

        public function ViewportOperator()
        {
        }

        public function initialize(_operatorMc:MovieClip, _manger:LogicManger):void
        {
            mOperatorMc = _operatorMc;
            mManger = _manger;
            mChangeScreenSizeConfirmBtn = mOperatorMc["changeScreenSizeConfirmBtn"];
            mOriginalViewportSizeBtn = mOperatorMc["originalViewportSizeBtn"];
            mFixViewportSizeBtn = mOperatorMc["fixViewportSizeBtn"];
            mScreenWithTF = mOperatorMc["screenWithTF"];
            mScreenHeightTF = mOperatorMc["screenHeightTF"];

            addListener();
        }

        //==================================
        //== Private Function
        //==================================

        private function addListener():void
        {
            mChangeScreenSizeConfirmBtn.addEventListener(MouseEvent.MOUSE_DOWN, onClickChangeScreenSizeConfirmBtn);
            mOriginalViewportSizeBtn.addEventListener(MouseEvent.MOUSE_DOWN, onClickOriginalViewportSizeBtn);
            mFixViewportSizeBtn.addEventListener(MouseEvent.MOUSE_DOWN, onClickFixViewportSizeBtn);
        }


        private function onClickChangeScreenSizeConfirmBtn(e:MouseEvent):void
        {
            mManger.onClickChangeScreenSizeConfirmBtn(int(mScreenWithTF.text), int(mScreenHeightTF.text));
        }

        private function onClickOriginalViewportSizeBtn(e:MouseEvent):void
        {
            mManger.onClickOriginalViewportSizeBtn();
        }

        private function onClickFixViewportSizeBtn(e:MouseEvent):void
        {
            mManger.onClickFixViewportSizeBtn();
        }


    }
}
